package com.shop2cn.iapi.grouponmgr.testcase;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.shop2cn.iapi.grouponmgr.parameter.GrouponProductInfoBean;
import com.shop2cn.iapi.grouponmgr.parameter.SaveGrouponReq;
import com.shop2cn.iapi.grouponmgr.service.GrouponProductInfoCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ImportAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyCatalogDto;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.Shop2cnGrouponCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.YMTDateUtil;

/**
 * 拼团商品详情Test FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GrouponProductInfo {
	private static GrouponProductInfoBean grouponproductinfoBean;
	private static GrouponProductInfoCall grouponproductinfoCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("拼团商品详情Test");
	}

	@Before
	public void caseUp() {
		grouponproductinfoBean = new GrouponProductInfoBean();
		grouponproductinfoCall = new GrouponProductInfoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(grouponproductinfoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_001() {
		Logger.start(true, "正确数据，查询拼团成功");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			// savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd
			// HH:mm:ss"));
			// Integer grouponProductId =
			// Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-2, "yyyy-MM-dd HH:mm:ss"));
			String dateBeforeOrNextSecond = YMTDateUtil
					.getDateBeforeOrNextSecond(YMTDateUtil.getSysTime("yyyy-MM-dd HH:mm:ss"), 10);
			savegrouponBean.setEndTime(dateBeforeOrNextSecond);
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			grouponproductinfoBean.setSellerId(mchId);

			grouponproductinfoBean.setGrouponProductId(grouponProductId);

			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_002() {
		Logger.start(true, "正确数据，查询进行中的拼团");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-2, "yyyy-MM-dd HH:mm:ss"));
			savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(3, "yyyy-MM-dd HH:mm:ss"));
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			grouponproductinfoBean.setSellerId(mchId);

			grouponproductinfoBean.setGrouponProductId(grouponProductId);

			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_003() {
		Logger.start(true, "正确数据，查询未开始拼团成功");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(2, "yyyy-MM-dd HH:mm:ss"));
			savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(3, "yyyy-MM-dd HH:mm:ss"));
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			grouponproductinfoBean.setSellerId(mchId);

			grouponproductinfoBean.setGrouponProductId(grouponProductId);

			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_004() {
		Logger.start(true, "正确数据，查询已结束拼团成功");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-2, "yyyy-MM-dd HH:mm:ss"));
			String dateBeforeOrNextSecond = YMTDateUtil
					.getDateBeforeOrNextSecond(YMTDateUtil.getSysTime("yyyy-MM-dd HH:mm:ss"), 3);
			savegrouponBean.setEndTime(dateBeforeOrNextSecond);
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			Thread.sleep(5000);
			grouponproductinfoBean.setSellerId(mchId);

			grouponproductinfoBean.setGrouponProductId(grouponProductId);

			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_005() {
		Logger.start(true, "没有输入活动状态，默认查询所有状态");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-2, "yyyy-MM-dd HH:mm:ss"));
			String dateBeforeOrNextSecond = YMTDateUtil
					.getDateBeforeOrNextSecond(YMTDateUtil.getSysTime("yyyy-MM-dd HH:mm:ss"), 10);
			savegrouponBean.setEndTime(dateBeforeOrNextSecond);
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			grouponproductinfoBean.setSellerId(mchId);

			grouponproductinfoBean.setGrouponProductId(grouponProductId);

			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_006() {
		Logger.start(true, "没有输入商户编号");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-1, "yyyy-MM-dd HH:mm:ss"));
			savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(3, "yyyy-MM-dd HH:mm:ss"));
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			// grouponproductinfoBean.setSellerId(mchId);

			grouponproductinfoBean.setGrouponProductId(grouponProductId);

			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("400", grouponproductinfoCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_007() {
		Logger.start(true, "拼团被删除，查询为空");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-2, "yyyy-MM-dd HH:mm:ss"));
			String dateBeforeOrNextSecond = YMTDateUtil
					.getDateBeforeOrNextSecond(YMTDateUtil.getSysTime("yyyy-MM-dd HH:mm:ss"), 3);
			savegrouponBean.setEndTime(dateBeforeOrNextSecond);
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			Thread.sleep(5000);

			Shop2cnGrouponCallService.DeleteGroupon(grouponProductId, mchId);
			grouponproductinfoBean.setSellerId(mchId);

			grouponproductinfoBean.setGrouponProductId(grouponProductId);

			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");


		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_008() {
		Logger.start(true, "商品被下架，提示商品下架");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(2, "yyyy-MM-dd HH:mm:ss"));
			savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(3, "yyyy-MM-dd HH:mm:ss"));
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			Thread.sleep(5000);
			
			AddAgentProductCallService.SetOffshelf(pid,mchId);
			
			Thread.sleep(5000);
			grouponproductinfoBean.setSellerId(mchId);
			
			grouponproductinfoBean.setGrouponProductId(grouponProductId);

			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");
			Logger.verifyEquals("商品下架", produ.get("exceptionReason").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_009() {
		Logger.start(true, "商品库存为0，查询出来了");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(2, "yyyy-MM-dd HH:mm:ss"));
			savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(3, "yyyy-MM-dd HH:mm:ss"));
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			Thread.sleep(5000);
			
			ModifyAgentProductBean initModifyAgentProductBean = AddAgentProductCallService.initModifyAgentProductBean(pid, addAgentProductBean);
			initModifyAgentProductBean.getCatalogList().forEach(b->{
				b.setStock(0);
			});
			AddAgentProductCallService.modifyAgentProduct(initModifyAgentProductBean);
			Thread.sleep(5000);
			
			grouponproductinfoBean.setSellerId(mchId);
			grouponproductinfoBean.setGrouponProductId(grouponProductId);
			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	//vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";
	private static int csId = AgentUsers.csId;
	private static String csName = "NickautoTest";
	//vip渠道->代理
	private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
	private static String vipAgentUserName1 = "dgsq408897016";
	private static int csId1 = AgentUsers.csId1;
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_010() {
		Logger.start(true, "代理价变更、");
		try {

			
			//vip渠道
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//vip代理1
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			String pid = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			
			
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(vipAgentUserId1,pid);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			
			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(vipAgentUserId1, pid, catalogList, 200d);
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);
			
			
			
			ModifyAgentProductBean initModifyAgentProductBean = AddAgentProductCallService.initModifyAgentProductBean(productId, addAgentProductBean);
			initModifyAgentProductBean.getCatalogList().forEach(b->{
//				b.setp
			});
			initModifyAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(201d);
			AddAgentProductCallService.modifyAgentProduct(initModifyAgentProductBean);
			
//			ModifyAgentProductBean initModifyAgentProductBeanByImportant = AddAgentProductCallService.initModifyAgentProductBeanByImportant(pid, importAgentProductBean);
//			double  price1 = 10000d;
//			List<DetailsCatalogDto> catalog = selectProductDetails.getCatalogList();
//			for (int i = 0; i < catalog.size(); i++) {
//				double agentPrice = catalog.get(i).getAgentPrice();
//				price1=agentPrice<price1?agentPrice:price1;
//			}
////			initModifyAgentProductBeanByImportant.getCatalogList().get(0).setDirectPrice(price1);
//			initModifyAgentProductBeanByImportant.getCatalogList().get(0).setMarketPrice(price1);
//			AddAgentProductCallService.modifyAgentProduct(initModifyAgentProductBeanByImportant);
			
			
			
			grouponproductinfoBean.setSellerId(vipAgentUserId1);
			grouponproductinfoBean.setGrouponProductId(grouponProductId);
			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

			
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase 
	public void Tc_GrouponProductInfo_011() {
		Logger.start(true, "多规格变单规格，查询商品详情");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-2, "yyyy-MM-dd HH:mm:ss"));
			savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(3, "yyyy-MM-dd HH:mm:ss"));
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			Thread.sleep(5000);
			
			ModifyAgentProductBean initModifyAgentProductBean = AddAgentProductCallService.initModifyAgentProductBean(pid, addAgentProductBean);
			ModifyCatalogDto modifyCatalogDto = initModifyAgentProductBean.getCatalogList().get(0);
			initModifyAgentProductBean.setCatalogList(Arrays.asList(modifyCatalogDto));
			AddAgentProductCallService.modifyAgentProduct(initModifyAgentProductBean);
			Thread.sleep(5000);
			
			grouponproductinfoBean.setSellerId(mchId);
			grouponproductinfoBean.setGrouponProductId(grouponProductId);
			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GrouponProductInfo_012() {
		Logger.start(true, "单规格变多规格，查询商品详情");
		try {
			Integer mchId = GodmchManageCallService.CreateSellerMch();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "AutoTest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList = new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId, pid);
			selectProductDetails.getCatalogList().forEach(a -> {
				catalogList.add(a.getCatalogId());
			});

			SaveGrouponReq savegrouponBean = Shop2cnGrouponCallService.initSaveGrouponReq(mchId, pid,
					catalogList.get(0), 100d);
			savegrouponBean.setBeginTime(YMTDateUtil.getBeforeOrNextDay(-2, "yyyy-MM-dd HH:mm:ss"));
			savegrouponBean.setEndTime(YMTDateUtil.getBeforeOrNextDay(3, "yyyy-MM-dd HH:mm:ss"));
			Integer grouponProductId = Shop2cnGrouponCallService.SaveGrouponCall(savegrouponBean);

			Thread.sleep(5000);
			
			ModifyAgentProductBean initModifyAgentProductBean = AddAgentProductCallService.initModifyAgentProductBean(pid, addAgentProductBean);
			ModifyCatalogDto modifyCatalogDto = initModifyAgentProductBean.getCatalogList().get(0);
			initModifyAgentProductBean.setCatalogList(Arrays.asList(modifyCatalogDto));
			AddAgentProductCallService.modifyAgentProduct(initModifyAgentProductBean);
			Thread.sleep(5000);
			
			grouponproductinfoBean.setSellerId(mchId);
			grouponproductinfoBean.setGrouponProductId(grouponProductId);
			grouponproductinfoCall.setData(grouponproductinfoBean);
			grouponproductinfoCall.callService();

			Logger.verifyEquals("200", grouponproductinfoCall.getString("code"), "验证code");
			JsonObject produ = grouponproductinfoCall.getJsonObject().getAsJsonObject("data");
			Logger.verifyEquals(grouponProductId, produ.get("grouponProductId").getAsInt(), "判断活动id是否正确");
			Logger.verifyEquals(pid, produ.get("productId").getAsString(), "判断商品id是否正确");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}